/**
* ...
* @author Default
* @version 0.1
*/

package bdz.common.display.core{
	import flash.display.Sprite;
	import bdz.common.utils.BitmapUtils;
	import flash.events.Event;
	import flash.utils.*;
	import org.papervision3d.cameras.FreeCamera3D;
	import org.papervision3d.scenes.MovieScene3D;
	
	
	// Import Papervision3D
	import org.papervision3d.scenes.InteractiveScene3D;
	import org.papervision3d.cameras.Camera3D;
	
	public class pv3DEnvironment extends Sprite {
		
		private var view_height:Number = 500;
		private var view_width:Number = 400;
		
		private var bounds:Sprite;
		
		protected var useCont:Sprite;
		protected var useScene:*;
		//pv3d elements
		protected var container:*;
		protected var camera:FreeCamera3D;
		protected var scene:*;
	
		
		function pv3DEnvironment(access:AbstractRestriction){
			if(access == null){
				throw new Error("NullPointerException on Abstract Class :: " + getQualifiedClassName(pv3DEnvironment));
			}
			addEventListener(Event.ADDED_TO_STAGE, initializeComponent);
			addEventListener(Event.REMOVED_FROM_STAGE, cleanUp);
		}
		protected static function getAccess():AbstractRestriction {
			return new AbstractRestriction();
		}
		protected function cleanUp(evt:Event):void{
			removeEventListener(Event.ADDED_TO_STAGE, initializeComponent);
			removeEventListener(Event.REMOVED_FROM_STAGE, cleanUp);
		}
		protected function initializeComponent(evt:Event):void{
			if(!useCont){
				container = new Sprite();
			}else{
				trace("using cont");
				container = useCont;
			}
			addChild( container );
		
			scene = new InteractiveScene3D( container );
		
			// Create camera
			
			
			camera = new FreeCamera3D();
			createElements();
		}
		protected function createElements():void{
			
		}
		
		protected function renderScene(evt:* = null):void{
			scene.renderCamera( camera );
		}
	}
	
}
class AbstractRestriction {}